import { request } from 'umi';
import type {PaymentLogItem} from "@/pages/PaymentLogs/data";

export async function queryPaymentLog(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
    type?: number;
    family?: number;
  },
  options?: Record<string, any>,
) {
  return request<{
    data: PaymentLogItem[];
    total: number;
    success?: boolean;
    status?: string;
    message?: string;
  }>('/api/paymentLog', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {})
  });
}

export async function updatePaymentLog(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/paymentLog', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

// 退款管理
export async function updatePaymentRefund(data: Record<string, any>, options?: Record<string, any>) {
  return request('/api/paymentLog/refund', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

export async function deletePaymentLog(data: { key: number }, options?: Record<string, any>) {
  return request<Record<string, any>>('/api/paymentLog', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}
